"""
数据容器-元组tuple
"""

my_tuple_1 = ("观止", 20, True, ("guanzhi", 20))
my_tuple_2 = ("观止", 20, True)
print(my_tuple_2)
print(type(my_tuple_1))

my_tuple_3 = ("a")
my_tuple_4 = ("a",)
print(type(my_tuple_3))
print(type(my_tuple_4))

# 获取值方式与列表一致
my_tuple = ((1, 2, 3), (4, 5, 6))
print(my_tuple[0][0])  # 打印 1

print(my_tuple[-1][-1])

# 如果元组内有list，可以对元组内list元素进行操作
my_tuple = (1, 2, [])
my_tuple[2].append("a")
my_tuple[2].extend(["b","c"])
print(my_tuple)
my_tuple[2].pop(0)
print(my_tuple)


# 常用操作
my_tuple = ("a", "b", "c", 1, 2, 3, 1)

# 查询元素下标
print(my_tuple.index(1))

# 统计元素个数
print(my_tuple.count(1))

# 统计元组长度
print(len(my_tuple))
